<?php
    class Template {
        private $file;
		private $values = array();
        
        public function __construct($file) {
            $this->file = $file;
        }
        
        public function set($key, $value) {
            $this->values[$key] = $value;
        }
        
        public function output() {
            if (!file_exists($this->file)) {
            	return "Error loading template";
            }
            
            $output = file_get_contents($this->file);
            
            foreach ($this->values as $key => $value) {
            	$tagToReplace = "[@$key]";
            	$output = str_replace($tagToReplace, $value, $output);
            }

            return $output;
        }

        static public function readTemplate($filename){
			$file = "templates/".$filename.".html";
			return $output = file_get_contents($file);
		}
    }
?>